//
//  OrderListTableViewCell.m
//  mcosApp
//
//  Created by YaSha_Tom on 2018/12/13.
//  Copyright © 2018年 YaSha-Tom. All rights reserved.
//

#import "OrderListTableViewCell.h"
@interface OrderListTableViewCell()
@property (nonatomic,strong) UILabel *timeLabel;//时间标签
@property (nonatomic,strong) UILabel *orderType;//订单状态
@property (nonatomic,strong) UIImageView *avatarImage;//头像
@property (nonatomic,strong) UILabel *orderName;//用户名称
@property (nonatomic,strong) UILabel *orderAdress;//地址
@property (nonatomic,strong) UIImageView *addressImage;//地址图片
@property (nonatomic,strong) UILabel *detailAddress;//详细地址
@property (nonatomic,strong) UILabel *moneryLabel;
@property (nonatomic,strong) UILabel *contractType;
@end
@implementation OrderListTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}
- (void)initUI {
    //时间标签设置
    self.timeLabel = [[UILabel alloc] init];
    self.timeLabel.font = [UIFont systemFontOfSize:15.0];
    [self addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.mas_top).offset(10);
        make.left.mas_equalTo(self.mas_left).offset(10);
        make.size.mas_equalTo(CGSizeMake(140*kWidthScale, 20*kHeightScale));
    }];
    
    //订单状态
    self.orderType = [[UILabel alloc] init];
    self.orderType.font = [UIFont systemFontOfSize:15.0];
    self.orderType.textColor = [UIColor colorWithRed:0.0/255.0 green:127.0/255.0 blue:252.0/255.0 alpha:1.0];
    self.orderType.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.orderType];
    [self.orderType mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.mas_top).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-10);
        make.size.mas_equalTo(CGSizeMake(150*kWidthScale, 20*kHeightScale));
    }];
    //用户头像
    self.avatarImage = [[UIImageView alloc] init];
    [self.avatarImage setImage:[UIImage imageNamed:@"缩略图"]];
    [self addSubview:self.avatarImage];
    [self.avatarImage mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(self.mas_left).offset(10);
        make.size.mas_equalTo(CGSizeMake(80*kWidthScale, 80*kHeightScale));
    }];
    //用户名称
    self.orderName = [[UILabel alloc] init];
    self.orderName.font = [UIFont systemFontOfSize:15.0];
    self.orderName.textColor = [UIColor grayColor];
    self.orderName.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.orderName];
    [self.orderName mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(self.avatarImage.mas_right).offset(5);
        make.size.mas_equalTo(CGSizeMake(150*kWidthScale, 20*kHeightScale));
    }];
    
    //金额
    self.moneryLabel = [[UILabel alloc]init];
    self.moneryLabel.font = [UIFont systemFontOfSize:15.0];
    self.moneryLabel.textColor = [UIColor blackColor];
    self.moneryLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.moneryLabel];
    [self.moneryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(self.orderName.mas_right).offset(5);
        make.size.mas_equalTo(CGSizeMake(120*kWidthScale, 20*kHeightScale));
    }];
    
    
    //用户地址设置
    self.orderAdress = [[UILabel alloc] init];
    self.orderAdress.font = [UIFont systemFontOfSize:15.0];
    self.orderAdress.textColor = [UIColor blackColor];
    [self addSubview:self.orderAdress];
    [self.orderAdress mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.orderName.mas_bottom).offset(5);
        make.left.mas_equalTo(self.avatarImage.mas_right).offset(5);
        make.size.mas_equalTo(CGSizeMake(258*kWidthScale, 20*kHeightScale));
    }];
    
    //详细地址
    self.detailAddress = [[UILabel alloc] init];
    self.detailAddress.font = [UIFont systemFontOfSize:15.0];
    self.detailAddress.textColor = [UIColor grayColor];
    self.detailAddress.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.detailAddress];
    [self.detailAddress mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.orderAdress.mas_bottom).offset(5);
        make.left.mas_equalTo(self.avatarImage.mas_right).offset(5);
        make.size.mas_equalTo(CGSizeMake(180*kWidthScale, 20*kHeightScale));
    }];
    
    //金额
    self.contractType = [[UILabel alloc]init];
    self.contractType.font = [UIFont systemFontOfSize:15.0];
    self.contractType.textColor = [UIColor colorWithRed:0.0/255.0 green:127.0/255.0 blue:252.0/255.0 alpha:1.0];
    self.contractType.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.contractType];
    [self.contractType mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.orderAdress.mas_bottom).offset(5);
        make.left.mas_equalTo(self.detailAddress.mas_right).offset(5);
        make.size.mas_equalTo(CGSizeMake(90*kWidthScale, 20*kHeightScale));
    }];
}
- (void)setOrderListData:(OrderListModel *)cellModel {
    NSLog(@"-----%@",cellModel);
    self.moneryLabel.hidden = YES;
    self.contractType.hidden = YES;
    self.timeLabel.text = cellModel.createTime;
    self.orderType.text = cellModel.statusName;
    self.orderName.text = cellModel.name;
    self.orderAdress.text = [NSString stringWithFormat:@"%@%@%@",cellModel.province,cellModel.city,cellModel.area];
    self.detailAddress.text = [NSString stringWithFormat:@"%@%@%@",cellModel.buildName,cellModel.buildGroupName,cellModel.address];
}
- (void)setContractListData:(ContractModel *)cellModel {
    self.moneryLabel.hidden = NO;
    self.contractType.hidden = NO;
    self.timeLabel.text = cellModel.wareName;
    self.orderType.text = cellModel.createTime;
    self.orderName.text = cellModel.firstName;
    self.moneryLabel.text = [NSString stringWithFormat:@"¥%@",cellModel.contrMoney];
    self.orderAdress.text = [NSString stringWithFormat:@"%@%@%@",cellModel.zxProvince,cellModel.zxCity,cellModel.zxDistrict];
    self.detailAddress.text = [NSString stringWithFormat:@"%@%@",cellModel.floorName,cellModel.floorGroupName];
    if ([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"108"])
    {
        self.contractType.text = @"合同处理中";
    }
    else if ([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"109"])
    {
        self.contractType.text = @"合同暂停";
    }
    else if([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"110"])
    {
        self.contractType.text = @"合同待接收";
    }
    else if([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"111"])
    {
        self.contractType.text = @"合同终止";
    }
    else if ([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"112"])
    {
        self.contractType.text = @"项目已接收";
    }
    else if ([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"113"])
    {
        self.contractType.text = @"项目待开工";
    }
    else if ([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"114"])
    {
       self.contractType.text = @"项目施工中";
    }
    else if ([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"115"])
    {
        self.contractType.text = @"项目暂停";
    }
    else if ([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"116"])
    {
        self.contractType.text = @"项目终止";
    }
    else if ([[NSString stringWithFormat:@"%@", cellModel.bstatus ] isEqualToString:@"117"])
    {
        self.contractType.text = @"项目竣工";
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
